<template>
  <div>
    <van-tabs v-model="activeName" @click="change">
      <van-tab
        :title="item.title1"
        :name="item.tab"
        v-for="(item, index) in lists"
        :key="index"
      >
        <Content :list1="list1" />
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import Content from "../components/Content";
export default {
  components: {
    Content,
  },
  data() {
    return {
      active: localStorage.getItem("tab") || "whole",
      activeName: "0",
      list1: [],
      lists: [
        {
          title1: "全部",
          tab: "ask",
        },
        {
          title1: "精华",
          tab: "share",
        },
        {
          title1: "分享",
          tab: "ask",
        },
        {
          title1: "问答",
          tab: "share",
        },
        {
          title1: "招聘",
          tab: "ask",
        },
        {
          title1: "客户端测试",
          tab: "share",
        },
      ],
    };
  },
  mounted() {
    // this.$axios.get("list.json").then((res) => {
    //   console.log(res);
    //   this.list1 = res.data.data;
    // });
    this.change()
  },
  methods: {
    change() {
      localStorage.setItem("tab", this.activeName);
      this.list1 = [];
      this.$axios.get("list.json").then((res) => {
        console.log(res);
        res.data.data.forEach((item) => {
          if (item.tab == this.activeName) {
            this.list1.push(item);
          }
        });
      });
    },
  },
};
</script>

<style lang="scss">
</style>